class PrintCategory < ActiveRecord::Base
  has_many :props, :class_name => 'PrintCategoryExt', :foreign_key => 'print_category_ext_id'
  has_many :product, :class_name => 'PrintProduct', :foreign_key => 'product_id'
  acts_as_tree :order => 'name', :foreign_key=> 'parent_id', :counter_cache => true
  
  validates_presence_of :name, :message => "必须填写分类名称"
  
  def PrintCategory.find_all_parent_category
    PrintCategory.find(:all, :conditions => 'parent_id = -1', :order => 'name asc')
  end
end